const express=require('express')
const path=require('path')
const app=express()
app.get('/user/:userID',(request,response)=>{
    const {userID}=request.params
    // 路径是字符串格式，如果要做数值判断需要转换
    if(userID!=='101'){
        return response.send({
            code:100,
            msg:'查询失败',
            data:null 
        })
    }
    response.send({
        code:101,
        msg:'查询成功',
        data:{
            name:'xiaok',
            age:18,
            sex:'男'
        }
    })
})
app.get('/1',(request,response)=>{
    const filePath=path.resolve(__dirname,'index.html')
    response.sendFile(filePath)
})
app.listen(9000,()=>{
    console.log('服务器部署成功 地址为http://127.0.0.1:9000')
})